package com.app.view.component.dialogs.pkResultView 
{
	import flash.display.MovieClip;
	
	import com.greensock.TweenLite;
	
	import com.app.view.component.room.seat.Paijiu;
	import com.peachcastle.core.Display;
	
	import com.peachcastle.debug.Log;
	
	/**
	 * ...
	 * @author kevin
	 */
	public class TieInfo extends Display
	{
		public static const COUNT:int = 4;
		
		private var _bankerPaijius:MovieClip = null;
		private var _bPaijius:Array = [];
		
		private var _playrPaijius:MovieClip = null;
		private var _pPaijius:Array = [];
		
		public function TieInfo(ui:MovieClip = null) 
		{
			super(ui, true);
		}
		
		override protected function initialization():void 
		{
			super.initialization();
			
			var i:int = 0;
			
			_bankerPaijius = assest["mc_tie_banker"];
			_bankerPaijius["txt_name"].text = "莊";
			_bankerPaijius["txt_title"].text = '';
			for (i = 0; i < COUNT; i++)
			{
				_bPaijius.push(new Paijiu(_bankerPaijius['pai_' + i]));
			}
			
			_playrPaijius = assest["mc_tie_playr"];
			_playrPaijius["txt_name"].text = "闲";
			_playrPaijius["txt_title"].text = '';
			for (i = 0; i < COUNT; i++)
			{
				_pPaijius.push(new Paijiu(_playrPaijius['pai_' + i]));
			}
		}
		
		override public function showAssest():void
		{
			alpha = 0;
			super.showAssest();
			
			TweenLite.to(assest, 1, { alpha:1 });
		}
		
		override public function hideAssest():void
		{
			super.hideAssest();
			
			reset();
		}
		
		private function reset():void
		{
			var i:int = 0;
			for (i = 0; i < COUNT; i++)
			{
				if(_bPaijius[i]) _bPaijius[i].resetHighlight();
			}
			
			for (i = 0; i < COUNT; i++)
			{
				if(_pPaijius[i]) _pPaijius[i].resetHighlight();
			}
		}
		
		public function setData(bankerPaijius:Array, playrPaijius:Array, bankerMax:int, playrMax:int):void
		{
			var paijiuType:Array = null;
			var i:int = 0;
			var len:int = bankerPaijius.length;
			var isHighlight:Boolean = false;
			var isUsed:Boolean = false;
			for (i = 0; i < len; i++)
			{
				isHighlight = false;
				if (bankerPaijius[i] == bankerMax && isUsed == false)
				{
					isHighlight = true;
					isUsed = true;
				}

				Paijiu(_bPaijius[i]).show(bankerPaijius[i], false, isHighlight);
			}
			paijiuType = Paijiu.getType(bankerMax);
			_bankerPaijius["txt_title"].text = paijiuType[1];
			
			isUsed = false;
			for (i = 0; i < len; i++)
			{
				isHighlight = false;
				if (playrPaijius[i] == playrMax && isUsed == false)
				{
					isHighlight = true;
					isUsed = true;
				}
				
				Paijiu(_pPaijius[i]).show(playrPaijius[i], false, isHighlight);
			}
			paijiuType = Paijiu.getType(playrMax);
			_playrPaijius["txt_title"].text = paijiuType[1];
			
		}
	}

}